#include "GameScene.h"


GameScene::GameScene() {

}


GameScene::~GameScene() {

}

bool GameScene::init() {
	if (Scene::initWithPhysics()) {
		this->getPhysicsWorld()->setGravity(Vect(0, -900));

		auto backgroundLayer = BackgroundLayer::create();
		if (backgroundLayer != NULL) {
			this->addChild(backgroundLayer);
		}

		//	Add the game status laerto show the score and game status
		auto statusLayer = StatusLayer::create();

		//	Add the main gam layer
		auto gameLayer = GameLayer::create();
		if (gameLayer != NULL) {
			gameLayer->setPhyWorld(this->getPhysicsWorld());
			gameLayer->setDelegator(statusLayer);
			this->addChild(gameLayer);
		}

		if (statusLayer != NULL) {
			this->addChild(statusLayer);
		}

		//	Add operation layer to control the game
		auto optionLayer = OptionLayer::create();
		if (optionLayer != NULL) {
			optionLayer->setDelegator(gameLayer);
			this->addChild(optionLayer);
		}

		return true;
	}

	return false;
}

void GameScene::restart() {
	this->removeAllChildrenWithCleanup(true);
	this->init();
}
